package com.zhenwei.zscm.controller;

import com.zhenwei.zscm.common.annotations.MethodName;
import com.zhenwei.zscm.common.base.RestResult;
import com.zhenwei.zscm.model.vo.orderProductRepair.OrderProductRepairVO;
import com.zhenwei.zscm.service.OrderProductRepairService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/order/product/repair")
@AllArgsConstructor
@MethodName("工单产品维修数据管理")
public class OrderProductRepairController {
    private OrderProductRepairService orderProductRepairService;

    @MethodName("添加工单产品维修数据")
    @PostMapping("/create")
    public RestResult create(@RequestBody @Valid OrderProductRepairVO vo){
        return orderProductRepairService.create(vo);
    }

    @MethodName("修改工单产品维修数据")
    @PostMapping("/update")
    public RestResult update(@RequestBody @Valid OrderProductRepairVO vo){
        return orderProductRepairService.update(vo);
    }

    @MethodName("获取工单产品维修数据明细")
    @GetMapping("/detail")
    public RestResult detail(@RequestParam @NotEmpty(message = "工单ID不能为空") String orderId, @RequestParam @NotEmpty(message = "产品SN不能为空") String productSn){
        return orderProductRepairService.detail(orderId, productSn);
    }
}
